<?php
		
	/* SVN FILE: $Id$ */
	
	/**
	* Project Name : arcadia
	*
	* @author $Author$
	* @version $Revision$
	* @lastrevision $Date$
	* @filesource $URL$
	*/

	include_once '../include/functions.php';

	function fnDivSummary($sWhat, $sTable, $aSummaryTable) {
		
		global $sAPP;
		
		$html  = $jsDocumentReady = '';
		$bShow = false;
		$sShowLabel = "mostra totale »";
		$sHideLabel = "nascondi totale «";

		if (isset($aSummaryTable['bShow']) && $aSummaryTable['bShow']) {
			$html .= "<div id='summary-toggle'>$sShowLabel</div>";
			$html .= "<table id='summary-table' border='".fnTableBorder()."' cellpadding='0' cellspacing='0' class='display dataTable' style='display:none'>";
			$html .= "	<tbody>
							<tr>
								<td colspan='2'>Lettura dei dati in corso...</td>
							</tr>
						</tbody>
						<tfoot>
							<tr>
								<th style='text-align:right'>".$aSummaryTable['sTotLabel']." &raquo; Totale:&nbsp;</th>
								<th style='text-align:left'></th>
							</tr>
						</tfoot>";
			$html .= "</table>";
			$bShow = true;

			$jsDocumentReady .= "
		   		$('#summary-toggle').click(function(){
		    		$('#summary-table').toggle('blind');
					$.getJSON('../include/summary.php', {'sField': 'summary', 'sAction': 'toggle', 'sTable': '$sTable', 'sAPP': '$sAPP' }, function(json) {
						if (json[0].sScript=='summary.php' && json[0].sAction=='toggle' && json[0].bSummaryShow=='true') { 
							$('#summary-toggle').text('$sShowLabel');
						} else {
							$('#summary-toggle').text('$sHideLabel');
						}	
					});
				});
		    
				if (".(is_null(fnReadSessionValue('bSummaryShow', 'main-table', $sAPP, $sTable)) || !fnReadSessionValue('bSummaryShow', 'main-table', $sAPP, $sTable) ? 'false' : 'true').") { /* FIXME */
					$('#summary-table').show();
					$('#summary-toggle').text('$sHideLabel'); 
				} ";
		}

		switch ($sWhat) {
			case 'jsDocumentReady':
				return $jsDocumentReady;	
				break;
			case 'html':
				return $html;	
				break;
			case 'bShow':
				return $bShow;	
				break;
			case 'aSettings':
				return $aSummaryTable['aSettings'];	
				break;	
			default:
				return array (	'jsDocumentReady' => $jsDocumentReady,
								'html' => $html,
								'bShow' => $bShow,
								'aSettings' => $aSummaryTable['aSettings']	);
		}

	}
?>
